{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "58cb88a9",
   "metadata": {},
   "source": [
    "----\n",
    "* 日期： 2022-10-19\n",
    "* python"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1037018e",
   "metadata": {},
   "source": [
    "# 本周学习内容\n",
    "\n",
    "> 1.列表的方法\n",
    "\n",
    "> 2.while 循环"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a1a83d9f",
   "metadata": {},
   "source": [
    "## 1.列表的方法\n",
    "> 1. 使用.tab键查看列表的方法\n",
    "> 2. 使用help(查看方法的使用规则)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "042b491e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 'Alex', 'Marry', 'Jan']"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names=[\"Jack\",\"Alex\",\"Marry\",\"Jan\"] \n",
    "names     "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a02071ae",
   "metadata": {},
   "source": [
    "## 1.1 列表的增加"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "13b43007",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.append(\"LiHua\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "e9e3ab50",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 'Alex', 'Marry', 'Jan', 'LiHua']"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "718b3766",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function append:\n",
      "\n",
      "append(object, /) method of builtins.list instance\n",
      "    Append object to the end of the list.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.append)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "fae8e148",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function insert:\n",
      "\n",
      "insert(index, object, /) method of builtins.list instance\n",
      "    Insert object before index.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.insert)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "18f2f33a",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.insert(2,\"Zhichao\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "ab52a483",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 'Alex', 'Zhichao', 'Marry', 'Jan', 'LiHua']"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5bb75d93",
   "metadata": {},
   "source": [
    "### 2. 列表的删除"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "63a9b3a1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function remove:\n",
      "\n",
      "remove(value, /) method of builtins.list instance\n",
      "    Remove first occurrence of value.\n",
      "    \n",
      "    Raises ValueError if the value is not present.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.remove)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "f614cc55",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.remove(\"Zhichao\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "b22590bc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 'Alex', 'Marry', 'Jan', 'LiHua']"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0efa00cb",
   "metadata": {},
   "source": [
    "* 正确的删除方法流程\n",
    "> 1. 查询value是否在列表当中 \n",
    "> 2. 对存在的value进行删除"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "2e0d9188",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"Wang\" in names"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "89082118",
   "metadata": {},
   "source": [
    "* names.remove(\"Wang\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "79765d78",
   "metadata": {},
   "outputs": [],
   "source": [
    "if \"Wang\" in names:\n",
    "    names.remove(\"Wang\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "c3b26e6e",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 实践：删除系统：1.如果输入的值存在，删除 2.如果输入的结果不存在，提示用户查询无结果     [用input要按回车键运行]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "cd1ff81d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 'Alex', 'Marry', 'Jan', 'LiHua']"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "72e21469",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入要删除的内容：Jack\n",
      "删除成功！\n",
      "['Alex', 'Marry', 'Jan', 'LiHua']\n"
     ]
    }
   ],
   "source": [
    "user_input_name=input(\"请输入要删除的内容：\")\n",
    "if user_input_name in names:\n",
    "    names.remove(user_input_name)\n",
    "    print(\"删除成功！\")\n",
    "else:\n",
    "    print(\"您输入的结果不存在，删除无效\")\n",
    "print(names)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9b1cc1bb",
   "metadata": {},
   "source": [
    "————————————————-------------------------------------------------------------------------------------------------------------\n",
    "* 列表的删除"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "c25e0e14",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 重新建立 names列表数据\n",
    "names=['Jack', 'Alex', 'Marry', 'Jan', 'LiHua']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "51849c0f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 'Alex', 'Marry', 'Jan', 'LiHua']"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "528b8153",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function remove:\n",
      "\n",
      "remove(value, /) method of builtins.list instance\n",
      "    Remove first occurrence of value.\n",
      "    \n",
      "    Raises ValueError if the value is not present.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.remove)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "57d24988",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function pop:\n",
      "\n",
      "pop(index=-1, /) method of builtins.list instance\n",
      "    Remove and return item at index (default last).\n",
      "    \n",
      "    Raises IndexError if list is empty or index is out of range.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help (names.pop)                  #index=-1 是默认的"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "a4426621",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'LiHua'"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.pop()      #pop() 直接使用则删除最后一位。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "969fe68e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 'Alex', 'Marry', 'Jan']"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "b0719d60",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Marry'"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.pop(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "86e461ff",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 'Alex', 'Jan']"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "b8e1b7f9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(names)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "d8a08a4f",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndexError",
     "evalue": "pop index out of range",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mIndexError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-25-a1a0532897ad>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mnames\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpop\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m5\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mIndexError\u001b[0m: pop index out of range"
     ]
    }
   ],
   "source": [
    "names.pop(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "15215ca5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "输入删除的索引值：2\n"
     ]
    }
   ],
   "source": [
    "pop_index=int(input(\"输入删除的索引值：\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "2707fa08",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "删除成功！\n"
     ]
    }
   ],
   "source": [
    "if pop_index<len(names):\n",
    "    names.pop(pop_index)\n",
    "    print(\"删除成功！\")\n",
    "else:\n",
    "    print(\"您输入的值不在index的范围内\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "f4cb14fd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 'Alex']"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "683eef99",
   "metadata": {},
   "source": [
    "### 3.列表的修改"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "71684843",
   "metadata": {},
   "outputs": [],
   "source": [
    "names[0]=\"Zhichao\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "d3160898",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Zhichao', 'Alex']"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1a631116",
   "metadata": {},
   "source": [
    "### 4.列表的其他方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "8f5b4f50",
   "metadata": {},
   "outputs": [],
   "source": [
    "names=['Jack', 'Alex', 'Marry', 'Jan', 'LiHua']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "393d8936",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.clear()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "308fa41a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "9d0389be",
   "metadata": {},
   "outputs": [],
   "source": [
    "names_class1=['Jack', 'Alex', 'Marry', 'Jan', 'LiHua']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "63341c21",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 'Alex', 'Marry', 'Jan', 'LiHua']"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names_class1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "08c9f9f8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function extend:\n",
      "\n",
      "extend(iterable, /) method of builtins.list instance\n",
      "    Extend list by appending elements from the iterable.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.extend)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "4d649282",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['李晓峰', '王丽', '刘铭']"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names_class2=[\"李晓峰\",\"王丽\",\"刘铭\"]\n",
    "names_class2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "03efc1e0",
   "metadata": {},
   "outputs": [],
   "source": [
    "names_class1.extend(names_class2)   #注意：使用列表的方法的列表进行拓展"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "98e7502f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Jack', 'Alex', 'Marry', 'Jan', 'LiHua', '李晓峰', '王丽', '刘铭']"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names_class1"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8826c994",
   "metadata": {},
   "source": [
    "————————————————————————————————————————————————————————————————————-\n",
    "* sort()排序"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "02719ade",
   "metadata": {},
   "outputs": [],
   "source": [
    "立定跳远_男生=[230,250,255,260,270,245]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "e14e35b5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function sort:\n",
      "\n",
      "sort(*, key=None, reverse=False) method of builtins.list instance\n",
      "    Sort the list in ascending order and return None.\n",
      "    \n",
      "    The sort is in-place (i.e. the list itself is modified) and stable (i.e. the\n",
      "    order of two equal elements is maintained).\n",
      "    \n",
      "    If a key function is given, apply it once to each list item and sort them,\n",
      "    ascending or descending, according to their function values.\n",
      "    \n",
      "    The reverse flag can be set to sort in descending order.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(立定跳远_男生.sort)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "0101072b",
   "metadata": {},
   "outputs": [],
   "source": [
    "立定跳远_男生.sort()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "7750a82e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[230, 245, 250, 255, 260, 270]"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "立定跳远_男生"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "64178717",
   "metadata": {},
   "outputs": [],
   "source": [
    "立定跳远_男生.sort(reverse=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "c181eee3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[270, 260, 255, 250, 245, 230]"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "立定跳远_男生"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "890fe9fe",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "7e2a8343",
   "metadata": {},
   "source": [
    "# 2. while 循环\n",
    "\n",
    "* while True 是循环概念中非常重要的一种方式，它可以实现for循环的指定次数，也可以在特定条件下停止。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "cc2a07ea",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "你是风儿我是沙，缠缠绵绵的天涯.... 0\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 1\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 2\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 3\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 4\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 5\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 6\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 7\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 8\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 9\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 10\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 11\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 12\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 13\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 14\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 15\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 16\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 17\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 18\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 19\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 20\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 21\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 22\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 23\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 24\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 25\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 26\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 27\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 28\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 29\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 30\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 31\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 32\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 33\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 34\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 35\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 36\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 37\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 38\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 39\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 40\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 41\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 42\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 43\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 44\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 45\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 46\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 47\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 48\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 49\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 50\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 51\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 52\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 53\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 54\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 55\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 56\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 57\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 58\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 59\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 60\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 61\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 62\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 63\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 64\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 65\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 66\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 67\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 68\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 69\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 70\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 71\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 72\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 73\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 74\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 75\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 76\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 77\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 78\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 79\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 80\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 81\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 82\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 83\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 84\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 85\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 86\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 87\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 88\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 89\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 90\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 91\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 92\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 93\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 94\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 95\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 96\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 97\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 98\n",
      "你是风儿我是沙，缠缠绵绵的天涯.... 99\n"
     ]
    }
   ],
   "source": [
    "# 死循环   它可以实现for循环的指定次数\n",
    "count=0\n",
    "while True:\n",
    "    print(\"你是风儿我是沙，缠缠绵绵的天涯....\",count)\n",
    "    count=count+1\n",
    "    if count==100:\n",
    "        break"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d0c6f45a",
   "metadata": {},
   "source": [
    "## 小游戏：猜数字，5次\n",
    "# 1. hide_card   :0-100, 大了小了\n",
    "# 2.guess_digit:50\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "a8d77537",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hide_card:········\n",
      "猜一猜（0-100）:333\n",
      "你超棒！\n"
     ]
    }
   ],
   "source": [
    "import getpass\n",
    "count=0\n",
    "hide_card==int(getpass.getpass(\"hide_card:\"))\n",
    "\n",
    "while True:\n",
    "    guess_digit=int(input(\"猜一猜（0-100）:\"))\n",
    "    #对比:\n",
    "    if hide_card==guess_digit:\n",
    "        print(\"你超棒！\")\n",
    "        break\n",
    "    elif guess_digit>hide_card:\n",
    "        print(\"往小猜！加油！\")\n",
    "    else:\n",
    "        print(\"往大的猜！\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c4f0d1a2",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "29064786",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "263a679d",
   "metadata": {},
   "source": [
    "# 课后作业：\n",
    "> 1. 列表的切片和方法的使用\n",
    ">> 1.1 课本  67  81  练习\n",
    "> 2. 89 列表的总结\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
